﻿@{
    ViewBag.Title = "SysMedicineAdd";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<style>
    #myTab {
        margin-top: 5px;
    }

    .span-x {
        float: left;
    }

    .span-dy {
        float: left;
        margin-left: 15px;
    }

    .disabled {
        pointer-events: none;
    }

    .ul-fybm {
        list-style: none;
    }

    .panel-heading {
        border-bottom: 1px solid #ccc;
    }
</style>
<script src="~/Content/js/medicine.js"></script>
<form id="form1">
    <div class="container">
        <ul class="nav nav-tabs" role="tablist" id="myTab">
            <li role="presentation" id="li_1"><a href="#basicInfo" role="tab" data-toggle="tab">基本信息</a></li>
            <li role="presentation" id="li_2"><a href="#antibioticInfo" id="li_antibioticInfo" class="disabled" role="tab" data-toggle="tab"> 抗生素信息</a></li>
        </ul>
        <div class="tab-content" style="margin-top:10px;padding-right:10px; overflow-y: auto; height: 660px;">
            <div id="basicInfo" role="tabpanel" class="tab-pane fade in active">
                <table class="form" style="width:98%;border:0">
                    <tr>
                        <td class="formTitle">
                            <span class="required">*</span>组织机构：
                        </td>
                        <td class="formValue" colspan="3">
                            <select id="OrganizeId" name="OrganizeId" class="form-control required">
                                <option value="">==请选择==</option>
                            </select>
                        </td>
                        <td class="formTitle">药品分类：</td>
                        <td class="formValue">
                            <input type="text" id="ypflMc" name="ypflMc" class="form-control" />
                            <input type="text" style="display:none;" id="ypflCode" name="ypflCode" class="form-control" />
                        </td>
                    </tr>
                    <tr>
                        <td class="formTitle">
                            <span class="required">*</span>药品名称：
                        </td>
                        <td class="formValue">
                            <input type="text" id="ypmc" name="ypmc" class="form-control required" />
                        </td>
                        <td class="formTitle">
                            <span class="required">*</span>首拼：
                        </td>
                        <td class="formValue">
                            <input type="text" id="py" name="py" class="form-control required" />
                        </td>
                        <td class="formTitle">
                            <span class="required">*</span>大类：
                        </td>
                        <td class="formValue">
                            <select id="dlCode" name="dlCode" class="form-control required">
                                <option value="">==请选择==</option>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td class="formTitle">
                            商品名：
                        </td>
                        <td class="formValue">
                            <input type="text" id="spm" name="spm" class="form-control" />
                        </td>
                        <td class="formTitle">
                            <span class="required">*</span>编码：
                        </td>
                        <td class="formValue">
                            <input type="text" id="ypCode" name="ypCode" class="form-control required" disabled="disabled" />
                        </td>
                        <td class="formTitle">
                            <span class="required">*</span>药厂名称：
                        </td>
                        <td class="formValue">
                            <input type="text" id="ycmc" name="ycmc" class="form-control" />
                        </td>
                    </tr>
                    <tr>
                        <td class="formTitle">批准文号：</td>
                        <td class="formValue">
                            <input type="text" id="pzwh" name="pzwh" class="form-control" />
                        </td>
                        <td class="formTitle" style="display:none">
                            新农合医保代码：
                        </td>
                        <td class="formValue" style="display:none">
                            <input type="text" id="xnhybdm" name="xnhybdm" class="form-control" />
                        </td>
                        <td class="formTitle">
                            <span class="required">*</span>药品规格：
                        </td>
                        <td class="formValue">
                            <input type="text" id="ypgg" name="ypgg" class="form-control required" />
                        </td>
                        <td class="formTitle">
                            <span class="required">*</span>剂型：
                        </td>
                        <td class="formValue">
                            <input type="text" id="jxmc" name="jxmc" autocomplete="off" class="form-control required" />
                            <input type="text" style="display:none;" id="jx" name="jx" class="form-control" />
                        </td>
                    </tr>
                    <tr>
                        <td class="formTitle"><span class="required">*</span>剂量单位：</td>
                        <td class="formValue">
                            <input type="text" id="jldw" name="jldw" class="form-control required" />
                        </td>
                        <td class="formTitle"><span class="required">*</span>剂量转换系数：</td>
                        <td class="formValue">
                            <input type="text" id="jl" name="jl" class="form-control required" />
                        </td>
                        <td class="formValue" colspan="2">
                            <p style="color:red;">1最小单位 = 剂量转换系数 * 剂量单位</p>
                        </td>
                    </tr>
                    <tr>
                        <td class="formTitle">默认剂量：</td>
                        <td class="formValue">
                            <input type="text" id="mrjl" name="mrjl" class="form-control" />
                        </td>
                        <td class="formTitle">默认频次：</td>
                        <td class="formValue">
                            <select id="mrpc" name="mrpc" class="form-control">
                                <option value="">==请选择==</option>
                            </select>
                        </td>
                        <td class="formTitle">抗生素：</td>
                        <td class="formValue">
                            <label><input type="radio" name="isKss" class="optionsRadios formClearIgnore" value="1" />是</label>&nbsp;&nbsp;&nbsp;
                            <label><input type="radio" name="isKss" class="optionsRadios formClearIgnore" checked="checked" value="0" />否</label>
                            <input type="hidden" id="kssId" name="kssId" class="form-control required" />
                        </td>
                    </tr>
                    <tr>
                        <td class="formTitle"><span class="required">*</span>医保标志：</td>
                        <td class="formValue">
                            <div class="ckbox">
                                <!-- 医保标志：即便有医保代码对照，也需要打上医保标志才会跟医保交互 -->
                                <select id="ybbz" name="ybbz" class="form-control required">
                                    <option value="">==请选择==</option>
                                    <option value="1">是</option>
                                    <option value="0">否</option>
                                </select>
                            </div>
                        </td>
                        <td class="formTitle">
                            国家医保代码：
                        </td>
                        <td class="formValue" colspan="2">
                            <input type="text" id="gjybdm" name="gjybdm" class="form-control" />
                        </td>
                    </tr>
                    <tr>
                        <td class="formTitle">
                            国家医保名称：
                        </td>
                        <td class="formValue">
                            <input type="text" id="gjybmc" name="gjybmc" class="form-control" />
                        </td>
                        <td class="formTitle">省医保代码：</td>
                        <td class="formValue">
                            <input type="text" id="ybdm" name="ybdm" class="form-control" />
                        </td>
                        <td class="formTitle">
                            默认用法：
                        </td>
                        <td class="formValue">
                            <input type="text" id="mryfmc" name="mryfmc" autocomplete="off" class="form-control" />
                            <input type="text" style="display:none;" id="mryf" name="mryf" class="form-control" />
                        </td>
                    </tr>
                    <tr>
                        <td class="formTitle">
                            <span class="required">*</span>自负性质：
                        </td>
                        <td class="formValue">
                            @*<div class="ckbox">

                <select id="zfxz" name="zfxz" class="form-control required">
                    <option value="">==请选择==</option>
                    <option value="1">自费</option>
                    <option value="4">甲类</option>
                    <option value="5">乙类</option>
                    <option value="6">丙类</option>
                </select>
            </div>*@
                            @Html.DropDownList("zfxz", Newtouch.Infrastructure.EnumZFXZv2.ZF.ToDescSelectList(), "==请选择==", new { @class = "form-control required" })
                        </td>
                        <td class="formTitle">自付比例：</td>
                        <td class="formValue">
                            <input type="text" id="zfbl" name="zfbl" class="form-control" />
                        </td>
                        <td class="formTitle">医保规格：</td>
                        <td class="formValue">
                            <input type="text" id="ybgg" name="ybgg" class="form-control" />
                        </td>
                    </tr>
                    <tr>
                        <th class="formTitle" valign="top" style="padding-top: 5px;">
                            备注：
                        </th>
                        <td class="formValue" colspan="5">
                            <textarea id="bz" name="bz" class="form-control" style="height: 60px;"></textarea>
                        </td>
                    </tr>
                </table>
                <div class="panel-heading">
                    单位转换 <p style="color:red;float:right">说明：1最小单位 = 剂量转换系数 * 剂量单位</p>
                </div>
                <div style="padding-right:5px;">
                    <table class="form">
                        <tr>
                            <td class="formTitle">
                                <span class="required">*</span>零售价：
                            </td>
                            <td class="formValue">
                                <input type="text" id="lsj" name="lsj" class="form-control required" onblur="lsjOnBlur();" />
                            </td>
                            <td class="formTitle">
                                批发价：
                            </td>
                            <td class="formValue">
                                <input type="text" id="pfj" name="pfj" class="form-control" @*onchange="getlsj()"*@ onblur="pfjOnBlur();" />
                            </td>
                            <td class="formTitle">
                                <span class="required">*</span>最小单位：
                            </td>
                            <td class="formValue">
                                <input type="text" id="zxdw" name="zxdw" class="form-control" onchange="changeZxdw()" />
                            </td>
                        </tr>
                        <tr>
                            <th class="formTitle"><span class="required">*</span>住院：</th>
                            <td class="formValue">
                                <input type="text" id="zycldw" name="zycldw" class="form-control required" placeholder="住院单位" />
                            </td>
                            <td class="formValue">
                                <span class="span-dy">=</span>
                                <span name="zxdw" class="span-dy"></span>
                                <span class="span-dy">x</span>
                            </td>
                            <td class="formValue">
                                <input type="text" id="zycls" name="zycls" class="form-control" placeholder="住院转化系数" />
                            </td>
                            <th class="formValue" style="color:red;" colspan="2">
                                <span name="zycls" class="span-dy"></span>
                                <span class="span-dy">x</span>
                                <span name="zxdw" class="span-dy"></span>
                                <span class="span-dy">=</span>
                                <span class="span-dy">1</span>
                                <span name="zycldw"></span>
                            </th>
                        </tr>
                        <tr>
                            <th class="formTitle">
                                <span class="required">*</span>门诊：
                            </th>
                            <td class="formValue">
                                <input type="text" id="mzcldw" name="mzcldw" class="form-control required" placeholder="门诊单位" />
                            </td>
                            <td class="formValue">
                                <span class="span-dy">=</span>
                                <span name="zxdw" class="span-dy"></span>
                                <span class="span-dy">x</span>
                            </td>
                            <td class="formValue">
                                <input type="text" id="mzcls" name="mzcls" class="form-control" placeholder="门诊转化系数" />
                            </td>
                            <th class="formValue" style="color:red;" colspan="2">
                                <span name="mzcls" class="span-dy"></span>
                                <span class="span-dy">x</span>
                                <span name="zxdw" class="span-dy"></span>
                                <span class="span-dy">=</span>
                                <span class="span-dy">1</span>
                                <span name="mzcldw"></span>
                            </th>
                        </tr>
                        <tr>
                            <th class="formTitle">
                                <span class="required">*</span>药库：
                            </th>
                            <td class="formValue">
                                <input type="text" id="bzdw" name="bzdw" class="form-control required " placeholder="药库单位" />
                            </td>
                            <td class="formValue">
                                <span class="span-dy">=</span>
                                <span name="zxdw" class="span-dy"></span>
                                <span class="span-dy">x</span>
                            </td>
                            <td class="formValue">
                                <input type="text" id="bzs" name="bzs" class="form-control" placeholder="药库转化系数" />
                            </td>
                            <th class="formValue" style="color:red;" colspan="2">
                                <span name="bzs" class="span-dy"></span>
                                <span class="span-dy">x</span>
                                <span name="zxdw" class="span-dy"></span>
                                <span class="span-dy">=</span>
                                <span class="span-dy">1</span>
                                <span name="bzdw"></span>
                            </th>
                        </tr>
                        <tr>
                            <td class="formTitle">
                                医保限价：
                            </td>
                            <td class="formValue">
                                <input type="text" id="ybdj" name="ybdj" class="form-control" oninput="value=value.replace(/[^0-9.]/g,'')" />
                            </td>
                            <td class="formTitle">
                                单次限量：
                            </td>
                            <td class="formValue">
                                <input type="text" id="dcxl" name="dcxl" class="form-control" oninput="value=value.replace(/[^0-9.]/g,'')" />
                            </td>
                            <td class="formTitle">
                                慢病限量：
                            </td>
                            <td class="formValue">
                                <input type="text" id="mbxl" name="mbxl" class="form-control" oninput="value=value.replace(/[^0-9.]/g,'')" />
                            </td>
                        </tr>
                    </table>
                </div>
                <div class="panel-heading">
                    药品属性
                </div>
                <table class="form" style="width:98%; height:80%; border:0">
                    <tr>
                        <td class="formTitle">招标方式：</td>
                        <td class="formValue">
                            <select id="zbbz" name="zbbz" class="form-control">
                                <option value="">==请选择==</option>
                            </select>
                        </td>
                        <td class="formTitle">药品属性：</td>
                        <td class="formValue">
                            <select id="yptssx" name="yptssx" class="form-control">
                                <option value="">==请选择==</option>
                            </select>
                        </td>
                        <td class="formTitle"><span class="required">*</span>病区记账类型：</td>
                        <td class="formValue">
                            @Html.DropDownList("jzlx", Newtouch.Infrastructure.EnumBQJZQZ.Day.ToDescSelectList(), "==请选择==", new { @class = "form-control required" })
                        </td>
                    </tr>
					<tr>
						<td class="formTitle"><span class="required">*</span>基药标识：</td>
						<td class="formValue" style="padding-top: 1px;">
							@Html.DropDownList("jybz", Newtouch.Infrastructure.EnumJybz.Gjy.ToDescSelectList(), "==请选择==", new { @class = "form-control required" })
						</td>
						<td class="formTitle">特殊药品标志：</td>
						<td class="formValue" style="padding-top: 1px;">
							<select id="tsypbz" name="tsypbz" class="form-control">
								<option value="">==请选择==</option>
							</select>
						</td>
						<td class="formTitle">选项：</td>
						<td class="formValue" style="padding-top: 1px;">
							<span class="ckbox">
								<input id="zt" name="zt" type="checkbox" checked="checked" /><label for="zt">有效</label>
							</span>
						</td>
					</tr>
                </table>
                <div class="panel-heading">
                    同步药/库房
                </div>
                <div>
                    <ul class="ul-fybm"></ul>
                </div>
            </div>
            <div id="antibioticInfo" role="tabpanel" class="tab-pane fade in">
                <table class="form" style="width:98%;border:0;">
                    <tr>
                        <td class="formTitle">
                            <span class="required">*</span>抗生素分类：
                        </td>
                        <td class="formValue">
                            <select id="kssType1" name="kssType1" class="form-control required">
                                <option value="">==请选择==</option>
                            </select>
                        </td>
                        <td class="formValue">
                            <select id="kssType2" name="kssType2" class="form-control">
                                <option value="">==请选择==</option>
                            </select>
                        </td>
                        <td class="formValue"></td>
                    </tr>
                    <tr>
                        <td class="formTitle">
                            <span class="required">*</span>权限级别：
                        </td>
                        <td class="formValue">
                            <select id="qxjb" name="qxjb" class="form-control">
                                <option value="0">非限制使用药物</option>
                                <option value="1">限制使用药物</option>
                                <option value="2">特殊使用药物</option>
                            </select>
                        </td>
                        <td class="formValue"></td>
                        <td class="formValue"></td>
                        <td class="formValue"></td>
                    </tr>
                    <tr>
                        <td class="formTitle">
                            单次剂量：
                        </td>
                        <td class="formValue" colspan="3">
                            <input type="number" id="jlfwks" name="jlfwks" class="form-control" style="width:130px;display:inline;" />
                            &nbsp;-&nbsp;
                            <input type="number" id="jlfwjs" name="jlfwjs" class="form-control" style="width:130px;display:inline;" />
                        </td>
                        @*<td class="formValue"></td>*@
                        
                    </tr>
                    <tr>
                        <td class="formTitle">
                            频次范围：
                        </td>
                        <td class="formValue" colspan="3">
                            <input type="number" id="pcfwks" min="0" name="pcfwks" class="form-control" style="width:130px;display:inline;"/>
                            &nbsp;-&nbsp;&nbsp;
                            <input type="number" id="pcfwjs" min="0" name="pcfwjs" class="form-control" style="width:130px;display:inline;"/>
                            (小时一次)
                        </td>
                        <td class="formValue"></td>
                    </tr>
                    <tr>
                        <td class="formTitle">
                            DDD值：
                        </td>
                        <td class="formValue" colspan="3">
                            <input type="number" id="DDDnum" name="DDDnum" class="form-control" style="width:120px;display:inline;"/>
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;DDD单位：&nbsp;&nbsp;&nbsp;&nbsp;
                            <input type="text" id="DDDdw" name="DDDdw" class="form-control" style="width:120px;display:inline;"/>
                        </td>
                        <td></td>
                    </tr>
                    <tr>
                        <td class="formTitle">剂量单位：</td>
                        <td class="formValue" colspan="3">
                            <input type="text" id="kssjldw" name="kssjldw" class="form-control" style="width:120px;display:inline;" />&nbsp;&nbsp;(单位g)
                        </td>
                        <td></td>
                    </tr>
                    <tr>
                        <td class="formTitle">
                            效价：
                        </td>
                        <td class="formValue" colspan="2">
                            <input type="number" id="xj" name="xj" class="form-control" style="width:120px;display:inline;"/>&nbsp;&nbsp;(单位mg)
                        </td>
                        <td></td>
                    </tr>
                    <tr>
                        <td class="formTitle">
                            空瓶：
                        </td>
                        <td class="formValue">
                            <label><input type="radio" name="kp" class="optionsRadios formClearIgnore" value="1" />是</label>&nbsp;&nbsp;&nbsp;
                            <label><input type="radio" name="kp" class="optionsRadios formClearIgnore" checked="checked" value="0" />否</label>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
</form>

<script>
    var keyValue = $.request("keyValue");
    $(function () {
        initControl();
        if (!!keyValue) {
            $("#OrganizeId").attr("disabled", "disabled");
            $.najax({
                url: "/SysMedicine/GetFormJson",
                data: { keyValue: keyValue },
                dataType: "json",
                async: false,
                success: function (data) {
                    $("#form1").formSerialize(data);
                    $("#jl").val(!!data.jl ? data.jl : '');
                    $("#zxdw").trigger("change");
                    $("#ybdj").val(data.cxjje);
                    $("span[name=zycls]").html(data.zycls);
                    $("span[name=zycldw]").html(data.zycldw);
                    $("span[name=mzcls]").html(data.mzcls);
                    $("span[name=mzcldw]").html(data.mzcldw);
                    $("span[name=bzs]").html(data.bzs);
					$("span[name=bzdw]").html(data.bzdw);
                    if (data.isKss == "1") {
                        $("#li_antibioticInfo").removeClass("disabled");
                    }
                    else if (data.isKss == "0") {
                        $("#li_antibioticInfo").addClass("disabled");
                    }
                    $("input:radio[name='isKss'][value='" + data.isKss + "']").attr("checked", "true");

                    $('#zfxz option[value=' + data.zfxz + ']').attr('selected', 'selected');
                }
            });
            if ($.trim($("#kssId").val()).length > 0) {
                //获取抗生素信息
                $.najax({
                    url: "/SysMedicine/GetKssById",
                    data: { Id: $("#kssId").val() },
                    dataType: "json",
                    async: false,
                    success: function (data) {
                        setLevelInfo(data.kssLevel1TypeId, data.kssLevel2TypeId, data.qxjb);
                        $("#qxjb").val(data.qxjb);
                        $("#jlfwks").val(data.jlfwBegin);
                        $("#jlfwjs").val(data.jlfwEnd);
                        $("#pcfwks").val(data.pcfwBegin);
                        $("#pcfwjs").val(data.pcfwEnd);
                        $("#DDDnum").val(data.DDDnum);
                        $("#DDDdw").val(data.DDDdw);
                        $("#xj").val(data.xj);
                        $("input:radio[name='kp'][value='" + data.kp + "']").attr("checked", "true");
                        $("#kssjldw").val(data.kssjldw);
                    }
                });
            }
        }
        else {
            var newOrgId = $.request('orgId');
            if (newOrgId) {
                $("#OrganizeId").val(newOrgId).trigger('change');
            }
        }
        initUnitChange();
    });

    //初始化单位换算
    function initUnitChange() {
        $("#zxdw").on("input", function () {
            changeZxdw();
        });
        $("#zycls").change(function () {
            $("span[name=zycls]").html($("#zycls").val());
        });
        $("#zycldw").change(function () {
            $("span[name=zycldw]").html($("#zycldw").val());
        });
        $("#zycls").on("input", function () {
            $("#zycls").trigger("change");
        });
        $("#zycldw").on("input", function () {
            $("#zycldw").trigger("change");
        });

        $("#mzcls").change(function () {
            $("span[name=mzcls]").html($("#mzcls").val());
        });
        $("#mzcldw").change(function () {
            $("span[name=mzcldw]").html($("#mzcldw").val());
        });
        $("#mzcls").on("input", function () {
            $("#mzcls").trigger("change");
        });
        $("#mzcldw").on("input", function () {
            $("#mzcldw").trigger("change");
        });

        $("#bzs").change(function () {
            $("span[name=bzs]").html($("#bzs").val());
        });
        $("#bzdw").change(function () {
            $("span[name=bzdw]").html($("#bzdw").val());
        });
        $("#bzs").on("input", function () {
            $("#bzs").trigger("change");
        });
        $("#bzdw").on("input", function () {
            $("#bzdw").trigger("change");
        });
    }

    //最小单位发生变化
    function changeZxdw() {
        $("span[name=zxdw]").html($("#zxdw").val());
    }

    function initControl() {
        $("#OrganizeId").bindSelect({//组织机构下拉框
            url: "/Organize/GetChildTreeSelectJson",
        });

        $("#OrganizeId").change(function () {
            //获取收费大类
            $("#dlCode").bindSelect({
                url: "/ChargeCategory/GetTreeSelectJson?organizeId=" + $.trim($('#OrganizeId').val()),
            });
            //招标方式
            $("#zbbz").bindSelect({
                url: "/ItemsData/GetSelectJson",
                param: { code: "MedicineTenderMethod" }
            });
            //药品特殊属性
            $("#yptssx").bindSelect({
                url: "/ItemsData/GetSelectJson",
                param: { code: "XT_YP_TSSX" }
			});
			
            $("#mrpc").bindSelect({
                url: "GetPcSelectJson"
			});
			//获取特殊药品标志
			$("#tsypbz").bindSelect({
				url: "/ItemsData/GetSelectJson",
				param: { code: "tsypbz" }
			});
        });

        //药品名称
        //$("#ypmc").ypFloatingSelector({
        //    itemdbclickhandler: function ($thistr) {
        //        //$('#ypmcsh').val($thistr.attr('data-ypmc'));
        //        $('#ypmc').val($thistr.attr('data-ypmc'));
        //        $('#ybdm').val($thistr.attr('data-ybdm'));
        //        $('#ypgg').val($thistr.attr('data-gg'));
        //        $('#ycmc').val($thistr.attr('data-ycmc'));
        //        $('#py').val($thistr.attr('data-py'));
        //        $('#ybdj').val($thistr.attr('data-dj'));
        //        $('#gjybdm').val($thistr.attr('data-gjybdm'));
        //        var zflb = $thistr.attr('data-ybxz');
        //        $('#zfxz option[value=' + zflb + ']').attr('selected', 'selected');
        //        $('#ybbz option[value=' + 1 + ']').attr('selected', 'selected');
        //    }
        //});
        //$('#ypmc').newtouchFloatingSelector({
        //    width: 600,
        //    height: 300,
        //    caption: "药品名称",
        //    url: '/SysMedicine/GetFloatingYPXXJson',
        //    ajaxparameters: function ($thistr) {
        //        return 'organizeId=' + $.trim($('#OrganizeId').val()) + '&keyword=' + $thistr;
        //        //return 'keyword=' + $.trim($('#ypmc').val());
        //    },
        //    itemdbclickhandler: function ($thistr) {
        //        //$('#ypmcsh').val($thistr.attr('data-ypmc'));
        //        $('#ypmc').val($thistr.attr('data-ypmc'));
        //        $('#ybdm').val($thistr.attr('data-ybdm'));
        //        $('#ypgg').val($thistr.attr('data-gg'));
        //        $('#ycmc').val($thistr.attr('data-ycmc'));
        //        $('#py').val($thistr.attr('data-py'));
        //        var zflb = $thistr.attr('data-ybxz');
        //        $('#zfxz option[value=' + zflb + ']').attr('selected', 'selected');
        //        $('#ybbz option[value=' + 1 + ']').attr('selected', 'selected');
        //    },
        //    colModel: [
        //        { label: '名称', name: 'ypmc', widthratio: 25 },
        //        { label: '医保代码', name: 'ybdm', widthratio: 20 },
        //        { label: '规格', name: 'gg', widthratio: 20 },
        //        { label: '药厂名称', name: 'ycmc', widthratio: 25 },
        //        { label: '药品性质', name: 'ypxz', widthratio: 25 },
        //        { label: '拼音', name: 'py', hidden: true },
        //        { label: '药品性质', name: 'ybxz', widthratio: 25 ,hidden:true}
        //    ]
        //});
        $('#xnhybdm').newtouchFloatingSelector({
            width: 540,
            height: 300,
            caption: "药品名称",
            url: '/SysMedicine/GetFloatingYPXNHXXJson',
            ajaxparameters: function () {
                return 'keyword=' + $.trim($('#xnhybdm').val());
            },
            itemdbclickhandler: function ($thistr) {
                //$('#ypmcsh').val($thistr.attr('data-ypmc'));
                $('#xnhybdm').val($thistr.attr('data-code'));
            },
            colModel: [
                { label: '名称', name: 'name', widthratio: 25 },
                { label: '农保代码', name: 'code', widthratio: 30 },
                { label: '剂型', name: 'dosageForm', widthratio: 30 },
                { label: '是否基药', name: 'isBase' }
            ]
        });
        //剂型信息
        $('#jxmc').newtouchFloatingSelector({
            width: 300,
            height: 200,
            caption: "剂型信息",
            url: '/SysMedicineFormulation/GetListSelectJson',
            ajaxparameters: function () {
                return "keyword=" + $.trim($('#jxmc').val());
            },
            itemdbclickhandler: function ($thistr) {
                $('#jx').val($thistr.attr('data-jxCode'));
                $('#jxmc').val($thistr.attr('data-jxmc'));
            },
            colModel: [{ label: '编码', name: 'jxCode', hidden: true },
            { label: '名称', name: 'jxmc', widthratio: 50 },
            { label: '首拼', name: 'py', widthratio: 50 }
            ]
        });

        //默认用法
        $('#mryfmc').newtouchFloatingSelector({
            width: 300,
            height: 300,
            caption: "用法",
            url: '/SysMedicine/GetUsageFloat',
            clickautotrigger: true,
            ajaxparameters: function () {
                return "keyword=" + $.trim($('#mryfmc').val());
            },
            itemdbclickhandler: function ($thistr) {
                $('#mryf').val($thistr.attr('data-yfCode'));
                $('#mryfmc').val($thistr.attr('data-yfmc'));
            },
            colModel: [{ label: '编码', name: 'yfCode', hidden: true },
                { label: '名称', name: 'yfmc', widthratio: 50 },
            { label: '首拼', name: 'py', widthratio: 50 }
            ]
        });

        //药品分类
        $('#ypflMc').newtouchFloatingSelector({
            width: 300,
            height: 300,
            caption: "药品分类",
            url: '/SysMedicineClassification/GetListSelectJson',
            clickautotrigger: true,
            ajaxparameters: function () {
                return "keyword=" + $.trim($('#ypflMc').val());
            },
            itemdbclickhandler: function ($thistr) {
                $('#ypflCode').val($thistr.attr('data-ypflCode'));
                $('#ypflMc').val($thistr.attr('data-ypflmc'));
            },
            colModel: [{ label: '编码', name: 'ypflCode', hidden: true },
            { label: '名称', name: 'ypflmc', widthratio: 50 },
            { label: '首拼', name: 'py', widthratio: 50 }
            ]
		});



		//药品名称
        $.fn.ypmcFloatingSelector = function (options) {
			var defaults = {
				url: '/SysMedicine/GetFloatingYPXXJson',
				width: 1300,
                height: 300,
                data: options,
				clickautotrigger: true,
				caption: "选择药品",
                ajaxparameters: function ($thisinput) {
					var key = $.trim($('#ypmc').val());
					if ($thisinput.selector =="#gjybdm") {
                        key = $.trim($('#gjybdm').val());
					}
                        return 'organizeId=' + $.trim($('#OrganizeId').val()) + '&keyword=' +key;
				},
				itemdbclickhandler: null,
				colModel: [
					{ label: '名称', name: 'ypmc', widthratio: 10 },
					{ label: '医保代码', name: 'ybdm', widthratio: 10 },
					{ label: '规格', name: 'gg', widthratio: 10 },
					{ label: '药厂名称', name: 'ycmc', widthratio: 20 },
					{ label: '批准文号', name: 'pzwh', widthratio: 10 },
					{ label: '药品性质', name: 'ypxz', widthratio: 10 },
					{ label: '药品性质', name: 'ybxz', widthratio: 15, hidden: true },
                    { label: '首拼', name: 'py', widthratio: 10, hidden: true },
					{ label: '医保限价', name: 'ybdj', widthratio: 10 },
					{ label: '国家医保代码', name: 'gjybdm', widthratio: 10 },
					{ label: '剂型', name: 'jxmc', widthratio: 10 }
				]
            };

            var options = $.extend(defaults, options);

                $(this).newtouchFloatingSelector(options);
        }
		
        $("#ypmc").ypmcFloatingSelector({
            organizeId: $.trim($('#OrganizeId').val()),
			//width: 1200,
            itemdbclickhandler: function ($thistr) {
                var curData = $.currentWindow().document.getElementById('gridList');
                var rowIds = jQuery(curData).jqGrid('getDataIDs');
                for (var k = 0; k < rowIds.length; k++) {
                    var curRowData = jQuery(curData).jqGrid('getRowData', rowIds[k]);
                    if ($thistr.attr('data-gjybdm') != "" && $thistr.attr('data-gjybdm') != null && curRowData.gjybdm == $thistr.attr('data-gjybdm')) {
                        $.modalAlert("系统已存在国家医保代码为" + $thistr.attr("data-gjybdm")+"的药品，"+$thistr.attr("data-ypmc"),'warning');
                    };
                };
				$('#ypmc').val($thistr.attr('data-ypmc'));
				$('#ybdm').val($thistr.attr('data-ybdm'));
				$('#ypgg').val($thistr.attr('data-gg'));
				$('#ycmc').val($thistr.attr('data-ycmc'));
				$('#py').val($thistr.attr('data-py'));
                $('#ybdj').val($thistr.attr('data-ybdj'));
                $('#gjybdm').val($thistr.attr('data-gjybdm'));
                $('#jxmc').val($thistr.attr('data-jxmc'));
                var zflb = $thistr.attr('data-ybxz');
                $('#zfxz option[value=' + zflb + ']').attr('selected', 'selected');
                $('#ybbz option[value=' + 1 + ']').attr('selected', 'selected');
			}
		});


		$("#gjybdm").ypmcFloatingSelector({
            organizeId: $.trim($('#OrganizeId').val()),
			//width: 1200,
			itemdbclickhandler: function ($thistr) {
				var curData = $.currentWindow().document.getElementById('gridList');
				var rowIds = jQuery(curData).jqGrid('getDataIDs');
				for (var k = 0; k < rowIds.length; k++) {
					var curRowData = jQuery(curData).jqGrid('getRowData', rowIds[k]);
					//if ($thistr.attr('data-gjybdm') != "" && $thistr.attr('data-gjybdm') != null && curRowData.gjybdm == $thistr.attr('data-gjybdm')) {
					//	$.modalAlert("系统已存在国家医保代码为" + $thistr.attr("data-gjybdm") + "的药品，" + $thistr.attr("data-ypmc"), 'warning');
					//};
				};
                if (($('#ypmc').val() != "" || $('#ypmc').val() != null) && $('#ybdm').val() != $thistr.attr('data-ybdm')) {
					$.modalConfirm("是否更新当前药品医保信息？", function (flag) {
                        if (flag) {
							//$('#ypmc').val($thistr.attr('data-ypmc'));
							$('#ybdm').val($thistr.attr('data-ybdm'));
							//$('#ypgg').val($thistr.attr('data-gg'));
							//$('#ycmc').val($thistr.attr('data-ycmc'));
							//$('#py').val($thistr.attr('data-py'));
							//$('#ybdj').val($thistr.attr('data-ybdj'));
							$('#gjybdm').val($thistr.attr('data-gjybdm'));
							//$('#jxmc').val($thistr.attr('data-jxmc'));
							var zflb = $thistr.attr('data-ybxz');
							$('#zfxz option[value=' + zflb + ']').attr('selected', 'selected');
                            $('#ybbz option[value=' + 1 + ']').attr('selected', 'selected');
                            var zflb = $thistr.attr('data-ybxz');
                            //$('#zfxz option[value=' + zflb + ']').attr('selected', 'selected');
                            $("#zfxz").val(zflb);
                            //$('#ybbz option[value=' + 1 + ']').attr('selected', 'selected');
                            $("#ybbz").val(1)
                            $("#pzwh").val($thistr.attr('data-pzwh'))
                            $("#gjybmc").val($thistr.attr('data-ypmc'))
						}
					})
				}

			}
		});

    //    //药品名称
    //    $('#ypmc').newtouchFloatingSelector({
    //        width: 540,
    //        height: 300,
    //        caption: "药品名称",
    //        url: '/SysMedicine/GetFloatingYPXXJson',
    //        ajaxparameters: function () {
    //            return 'organizeId='+ $.trim($('#OrganizeId').val())+'&keyword='+$.trim($('#ypmc').val());
    //            //return 'keyword=' + $.trim($('#ypmc').val());
    //        },
    //        itemdbclickhandler: function ($thistr) {
    //            //$('#ypmcsh').val($thistr.attr('data-ypmc'));
    //            $('#ypmc').val($thistr.attr('data-ypmc'));
    //            $('#ybdm').val($thistr.attr('data-ybdm'));
    //            $('#ypgg').val($thistr.attr('data-gg'));
				//$('#ycmc').val($thistr.attr('data-ycmc'));
				//$('#py').val($thistr.attr('data-py'));
    //            var zflb = $thistr.attr('data-ybxz');
    //            $('#zfxz option[value=' + zflb + ']').attr('selected', 'selected');
				//$('#ybbz option[value=' + 1 + ']').attr('selected', 'selected');
				////$('#ypmc').html($thistr.attr('data-ypmc'));
    //        },
    //        colModel: [
    //            { label: '名称', name: 'ypmc', widthratio: 20 },
    //            { label: '医保代码', name: 'ybdm', widthratio: 15 },
    //            { label: '规格', name: 'gg', widthratio: 15 },
    //            { label: '药厂名称', name: 'ycmc', widthratio: 20 },
    //            { label: '药品性质', name: 'ypxz', widthratio: 15 },
				//{ label: '药品性质', name: 'ybxz', widthratio: 25, hidden: true },
				//{ label: '首拼', name: 'py', widthratio: 15 },
    //        ]
    //    });

		//新农合医保代码
		$.fn.xnhFloatingSelector = function (options) {
			var defaults = {
				url: '/SysMedicine/GetFloatingYPXNHXXJson',
				width: 540,
				height: 300,
				clickautotrigger: true,
				caption: "药品名称",
				ajaxparameters: function ($thisinput) {
					return 'keyword=' + $.trim($('#xnhybdm').val());
				},
				itemdbclickhandler: null,
				colModel: [
					{ label: '名称', name: 'name', widthratio: 25 },
					{ label: '农保代码', name: 'code', widthratio: 30 },
					{ label: '剂型', name: 'dosageForm', widthratio: 30 },
					{ label: '是否基药', name: 'isBase' }
				]
			};
			var options = $.extend(defaults, options);

			$(this).newtouchFloatingSelector(options);
		}

		$("#xnhybdm").xnhFloatingSelector({
			width: 540,
			itemdbclickhandler: function ($thistr) {
				$('#xnhybdm').val($thistr.attr('data-code'));
			}
		});

  //      $('#xnhybdm').newtouchFloatingSelector({
  //          width: 540,
  //          height: 300,
  //          caption: "药品名称",
  //          url: '/SysMedicine/GetFloatingYPXNHXXJson',
  //          ajaxparameters: function () {
  //              return 'keyword=' + $.trim($('#xnhybdm').val());
  //          },
  //          itemdbclickhandler: function ($thistr) {
  //              //$('#ypmcsh').val($thistr.attr('data-ypmc'));
  //              $('#xnhybdm').val($thistr.attr('data-code'));
  //          },
  //          colModel: [
  //              { label: '名称', name: 'name', widthratio: 25 },
  //              { label: '农保代码', name: 'code', widthratio: 30 },
  //              { label: '剂型', name: 'dosageForm', widthratio: 30 },
  //              { label: '是否基药', name: 'isBase' }
  //          ]
		//});

		//剂型信息
		$.fn.jxFloatingSelector = function (options) {
			var defaults = {
				url: '/SysMedicineFormulation/GetListSelectJson',
				width: 300,
				height: 200,
				clickautotrigger: true,
				caption: "剂型信息",
				ajaxparameters: function ($thisinput) {
					return "keyword=" + $.trim($('#jxmc').val());
				},
				itemdbclickhandler: null,
				colModel: [{ label: '编码', name: 'jxCode', hidden: true },
				{ label: '名称', name: 'jxmc', widthratio: 50 },
				{ label: '首拼', name: 'py', widthratio: 50 }
				]
			};
			var options = $.extend(defaults, options);

			$(this).newtouchFloatingSelector(options);
		}
		$("#jxmc").jxFloatingSelector({
			//organizeId: $.trim($('#OrganizeId').val()),
			width: 300,
			itemdbclickhandler: function ($thistr) {
				$('#jx').val($thistr.attr('data-jxCode'));
				$('#jxmc').val($thistr.attr('data-jxmc'));
			}
		});
        ////剂型信息
        //$('#jxmc').newtouchFloatingSelector({
        //    width: 300,
        //    height: 200,
        //    caption: "剂型信息",
        //    url: '/SysMedicineFormulation/GetListSelectJson',
        //    ajaxparameters: function () {
        //        return "keyword=" + $.trim($('#jxmc').val());
        //    },
        //    itemdbclickhandler: function ($thistr) {
        //        $('#jx').val($thistr.attr('data-jxCode'));
        //        $('#jxmc').val($thistr.attr('data-jxmc'));
        //    },
        //    colModel: [{ label: '编码', name: 'jxCode', hidden: true },
        //    { label: '名称', name: 'jxmc', widthratio: 50 },
        //    { label: '首拼', name: 'py', widthratio: 50 }
        //    ]
        //});

		//药品单位
		$.fn.ypdwFloatingSelector = function (options) {
			var defaults = {
				url: '/SysMedicineUnit/GetListSelectJson',
				width: 300,
				height: 300,
				clickautotrigger: true,
				caption: "药品单位",
				ajaxparameters: function ($thisinput) {
					return "keyword=" + $.trim($thisinput.val());
				},
				itemdbclickhandler: null,
				colModel: [
					{ label: '名称', name: 'ypdwmc', widthratio: 50 }
				]
			};
			var options = $.extend(defaults, options);

			$(this).newtouchFloatingSelector(options);
		}

		$("#jldw").ypdwFloatingSelector({
			organizeId: $.trim($('#OrganizeId').val()),
			width: 300,
			itemdbclickhandler: function ($thistr, $thisinput) {
				$($thisinput.val($thistr.attr('data-ypdwmc'))).trigger("change");
			}
        });
		$("#zxdw").ypdwFloatingSelector({
			organizeId: $.trim($('#OrganizeId').val()),
			width: 300,
			itemdbclickhandler: function ($thistr, $thisinput) {
				$($thisinput.val($thistr.attr('data-ypdwmc'))).trigger("change");
			}
		});
		$("#zycldw").ypdwFloatingSelector({
			organizeId: $.trim($('#OrganizeId').val()),
			width: 300,
			itemdbclickhandler: function ($thistr, $thisinput) {
				$($thisinput.val($thistr.attr('data-ypdwmc'))).trigger("change");
			}
		});
		$("#mzcldw").ypdwFloatingSelector({
			organizeId: $.trim($('#OrganizeId').val()),
			width: 300,
			itemdbclickhandler: function ($thistr, $thisinput) {
				$($thisinput.val($thistr.attr('data-ypdwmc'))).trigger("change");
			}
		});
		$("#bzdw").ypdwFloatingSelector({
			organizeId: $.trim($('#OrganizeId').val()),
			width: 300,
			itemdbclickhandler: function ($thistr, $thisinput) {
				$($thisinput.val($thistr.attr('data-ypdwmc'))).trigger("change");
			}
		});
        ////药品单位
        //$("#jldw,#zxdw,#zycldw,#mzcldw,#bzdw").newtouchBatchFloatingSelector({
        //    width: 300,
        //    height: 300,
        //    caption: "剂型信息",
        //    url: '/SysMedicineUnit/GetListSelectJson',
        //    ajaxparameters: function ($thisinput) {
        //        return "keyword=" + $.trim($thisinput.val());
        //    },
        //    itemdbclickhandler: function ($thistr, $thisinput) {
        //        $($thisinput.val($thistr.attr('data-ypdwmc'))).trigger("change");
        //    },
        //    colModel: [
        //        { label: '名称', name: 'ypdwmc', widthratio: 50 }
        //    ]
        //});

        //$('#zfxz').select2();
        $('#jzlx').select2();

        //首拼
        $('#ypmc').keyup(function () {
            $('#py').val($(this).toShouPin());
        });

        //抗生素单选按钮控制Tab是否禁用
        $("input:radio[name='isKss']").change(function () {
            var opt = $("input:radio[name='isKss']:checked").val();
            if (opt == "1") {
                $("#li_antibioticInfo").removeClass("disabled");
            }
            else if (opt == "0") {
                $("#li_antibioticInfo").addClass("disabled");
            }
        });

        $("#kssType1").bindSelect({
            url: "/AntibioticType/GetSelectJson",
            param: { parentId: "" }
        });
        $("#kssType1").change(function () {
            var typeval = $("#kssType1").val();
            var qxjb = "0";
            var parentId = "";
            if (typeval != "") {
                parentId = typeval.split("|")[0];
                qxjb = typeval.split("|")[1];//一级分类变更时沿用权限级别
            }
            $("#qxjb").val(qxjb);
            $("#kssType2").bindSelect({
                url: "/AntibioticType/GetSelectJson",
                param: { parentId: parentId }
            });
        });
        $("#kssType2").change(function () {
            var typeval = $("#kssType2").val();
            if (typeval != "") {
                var qxjb = typeval.split("|")[1];//二级分类变更时沿用权限级别
                $("#qxjb").val(qxjb);
            }
        });
        InitYfbmByNewDrug();
    }

    //获取所有药房部门
    function InitYfbmByNewDrug() {
        $.najax({
            url: "/SysMedicine/GetAllYfbm",
            dataType: "json",
            success: function (data) {
                if (!!data.data) {
                    var o = JSON.parse(data.data);
                    if (!o || o.length === 0) return;
                    $.each(o, function (index, item) {
                        var tt = "<li><span class=\"ckbox\">";
                        tt += "<input id=\"yfbm_" + item.yfbmCode + "\" name=\"yfbm\" type=\"checkbox\" checked=\"checked\" value=\"" + item.yfbmCode + "\" /><label for=\"yfbm_" + item.yfbmCode + "\">" + item.yfbmmc + "</label>";
                        tt += "</span></li>";
                        $(".ul-fybm").append(tt);
                    });
                    RefreshEmpowermentPharmacyDepartment();
                }
            }
        });
    }

    //刷新授权药房
    function RefreshEmpowermentPharmacyDepartment() {
        if (!keyValue) return false;
        $.najax({
            url: "/SysMedicine/GetEmpowermentPharmacyDepartment",
            data: { ypId: keyValue },
            dataType: "json",
            async: false,
            success: function (data) {
                var allYfbmckb = $("input[name=yfbm]");
                if (allYfbmckb == null || allYfbmckb.length === 0) return false;
                for (var i = 0; i < allYfbmckb.length; i++) {
                    $(allYfbmckb[i]).prop("checked", false);
                    if (data !== null && data.length > 0) {
                        $.each(data, function (index, item) {
                            var id = "yfbm_" + item.yfbmCode;
                            if ($("#" + id) != null && $("#" + id).length > 0) $("#" + id).prop("checked", true);
                        });
                    }
                }
            }
        });
    }

    var anPrevOrg = null;
    $('#ypmc').blur(function () {
        var organizeId = $("#OrganizeId").val();
        if (!!!keyValue && ($.trim($(this).val()) === '' || organizeId !== anPrevOrg)) {
            anPrevOrg = organizeId;
            $.najax({
                url: "/HOME/GetNewFieldUniqueValue?topOrgIdIsStar=false&initFieldLength=8&fieldName=xt_yp.ypCode&orgId=" + organizeId + "&r=" + Math.random(),
                dataType: "json",
                cache: false,
                success: function (data) {
                    $('#ypCode').val(data.data);
                }
            });
        }
    });

    function submitForm() {//点击提交序列化
        debugger;
        if ($("#OrganizeId").val() == "") {
            $("#OrganizeId").focus();
            return false;
        }
        var reg = /^[1-9]\d*$/;//大于0的整数
        if (!reg.test($("#zycls").val())) {
            $.modalMsg("住院转化系数必须为大于0的整数！", "warning", 1500);
            $("#zycls").val("");
            return false;
        }
        if (!reg.test($("#mzcls").val())) {
            $.modalMsg("门诊转化系数必须为大于0的整数！", "warning", 1500);
            $("#mzcls").val("");
            return false;
        }
        if (!reg.test($("#bzs").val())) {
            $.modalMsg("药库转化系数必须为大于0的整数！", "warning", 1500);
            $("#bzs").val("");
            return false;
        }
        if (parseFloat($("#jlfwks").val()) > parseFloat($("#jlfwjs").val()) && $.trim($("#jlfwjs").val()) != "") {
            $.modalMsg("抗生素单次剂量，剂量最小值不能大于剂量最大值！", "warning", 1500);
            return false;
        }
        if (parseFloat($("#pcfwks").val()) > parseFloat($("#pcfwjs").val()) && $.trim($("#jlfwjs").val()) != "") {
            $.modalMsg("抗生素频次范围，频次最小值不能大于频次最大值！", "warning", 1500);
            return false;
        }
        if ($('input:radio[name=isKss]:checked').val() == "1" && $("#kssType1").val() == "") {
            $.modalMsg("抗生素药品必须录入抗生素类型！", "warning", 1500);
            return false;
        }

        if ($("#ybbz").val() == 1 && ($("#ybdm").val() == "" || $("#ybdm").val() == null)) {
            //$.modalMsg("请录入医保代码！", "warning", 1500);
            //return false;
        }

        //取消国家医保代码必填项
        //if ($("#ybbz").val() == 1 && ($("#gjybdm").val() == "" || $("#gjybdm").val() == null)) {
        //    $.modalMsg("请录入国家医保代码！", "warning", 1500);
        //    return false;
        //}
        
        if (!$('#form1').formValid()) return false;

        var kssId = "";
        debugger
        var postData = $("#form1").formSerialize();
        postData.isKss = $('input:radio[name=isKss]:checked').val();
        if (postData.isKss === "1") {
            kssId = SaveKss(); //抗生素信息保存
        }
        postData.mryf = $("#mryfmc").val() == "" ? "" : $("#mryf").val();
        postData["djdw"] = postData["bzdw"]; //2018.04.18
        postData.kssId = kssId;
        $.submitForm({
            url: "/SysMedicine/submitForm?keyValue=" + keyValue,
            param: { model: postData, p: AssembleEmpowermentPharmacyDepartment(), ypCode: $("#ypCode").val() },
            async: false,
            success: function () {
                $.currentWindow().$("#gridList").resetSelection();
                $.currentWindow().$("#gridList").trigger("reloadGrid");
            }
        });
    }

    ////提交授权库房
    //function SubmitEmpowermentPharmacyDepartment() {
    //    $.najax({
    //        url: "/SysMedicine/SubmitEmpowermentPharmacyDepartment?keyValue=" + keyValue,
    //        dataType: "json",
    //        data: { p: AssembleEmpowermentPharmacyDepartment(), ypCode: $("#ypCode").val() },
    //        success: function (data) { }
    //    });
    //}

    //组装被选中的药房药库
    function AssembleEmpowermentPharmacyDepartment() {
        var chk = $("input:checkbox[name=yfbm]:checked");
        if (chk === null || chk.length === 0) return false;
        var param = [];
        chk.each(function (index, item) {
            param.push($(this).val());
        });
        return param;
    }

    function SaveKss()//提交抗生素信息
    {
        var kssData = new Object();
        kssData.Id = $("#kssId").val();
        kssData.ypId = keyValue;
        var typeval1 = $("#kssType1").val();
        if (typeval1 != "") {
            kssData.kssLevel1TypeId = typeval1.split("|")[0];
        }
        var typeval2 = $("#kssType2").val();
        if (typeval2 != "") {
            kssData.kssLevel2TypeId = typeval2.split("|")[0];
        }
        kssData.qxjb = $("#qxjb").val();
        kssData.jlfwBegin = $("#jlfwks").val();
        kssData.jlfwEnd = $("#jlfwjs").val();
        kssData.pcfwBegin = $("#pcfwks").val();
        kssData.pcfwEnd = $("#pcfwjs").val();
        kssData.DDDnum = $("#DDDnum").val();
        kssData.DDDdw = $("#DDDdw").val();
        kssData.xj = $("#xj").val();
        kssData.kssjldw = $("#kssjldw").val();
        kssData.kp = $('input:radio[name=kp]:checked').val();
        var returnId = "";
        $.ajax({
            url: "/SysMedicine/SubmitKssForm",
            data: kssData,
            async: false,
            type: "post",
            dataType: "json",
            success: function (data) {
                if (data != null && data.data !== "") returnId = data.data;
            }
        });
        return returnId;
    }

    function setLevelInfo(type1, type2, qxjb) {
        if (type1 !== "") {
            var result1 = "";
            $("#kssType1 option").each(function () {
                //遍历所有option
                var value = $(this).val();   //获取option值
                if (value.indexOf(type1) > -1) {
                    result1 = value;
                    return;
                }
            });
            $("#kssType1").val(result1).trigger("change");
            if (type2 != "") {
                setTimeout(function () {
                    var result2 = "";
                    $("#kssType2 option").each(function () {
                        //遍历所有option
                        var value = $(this).val(); //获取option值
                        if (value.indexOf(type2) > -1) {
                            result2 = value;
                            return;
                        }
                    });
                    $("#kssType2").val(result2).trigger("change");
                    $("#qxjb").val(qxjb);
                },
                    500);
            }
        }
	}
    //说明：这边会自动改零售价，温江不需要。
	//function getlsj() {
	//	var pfj = $("#pfj").val();
	//	//alert(pfj);
	//	var itemCode = "MedicineCoefficient";
	//	var itemDetailsName = "TradePricePlus";
	//	$.ajax({
	//		url: "/SysMedicine/GetItemDetailsByCode",
	//		data: { name:"TradePricePlus"},
	//		async: false,
	//		type: "post",
	//		dataType: "json",
	//		success: function (data) {
 //               var lsj = pfj * data * 1;
 //               lsj = parseFloat(lsj).toFixed(4);
	//			$("#lsj").val(lsj);
	//		}
	//	});

 //   }


    function lsjOnBlur() {
        var resultlsj = $("#lsj").val();
        if (resultlsj == null || resultlsj == undefined || resultlsj == "") {
            return;
        } else{
            resultlsj = parseFloat(resultlsj).toFixed(4);
            $("#lsj").val(resultlsj);
        }
    }

    function pfjOnBlur() {
        var resultpfj = $("#pfj").val();
        if (resultpfj == null || resultpfj == undefined || resultpfj == "") {
            return;
        } else {
            resultpfj = parseFloat(resultpfj).toFixed(4);
            $("#pfj").val(resultpfj);
        }
    }
    
</script>